import { Mapbox } from "@antv/l7";
import { scene } from "../../context";

// 东营
// export const LOCATION_DONGYING: [number, number] = [118.524899, 37.5410248];
//仁怀市
// export const LOCATION_DONGYING: [number, number] = [106.41328, 27.81161];
// 茅坝村
const LOCATION_DONGYING: [number, number] = [106.17533, 27.71668];

const defineScene = async () => {
    const mapId = "base-map";
    const map = await scene.createModule(
        "MapModule",
        {
            scene: {
                id: mapId,
                map: new Mapbox({
                    style: "blank",
                    zoom: 15,
                    center: LOCATION_DONGYING,
                    minZoom: 3,
                    maxZoom: 20
                }),
                logoVisible: false
            }
        },
        false
    );
    await scene.createView(
        "MapView",
        {
            // MapModule: {
            //     scene: {
            //         id: "base-map",
            //         map: new Mapbox({
            //             style: "blank",
            //             zoom: 15,
            //             center: LOCATION_DONGYING,
            //             minZoom: 3,
            //             maxZoom: 20
            //         }),
            //         logoVisible: false
            //     }
            // },
            mapId
        },
        {
            MapModule: map
        }
    );
    scene.init();
};

export const useScene = () => {
    onMounted(async () => {
        await defineScene();
    });
    return scene;
};
